package com.lianzhihui.romeex.ui.ecological;

import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.lianzhihui.romeex.R;
import com.lianzhihui.romeex.bean.MnnerTransferListBean;
import com.lianzhihui.romeex.bean.TradeRecordBean;
import com.lianzhihui.romeex.config.AppConstants;
import com.lianzhihui.romeex.ui.base.BaseActivity;
import com.lianzhihui.romeex.utils.DateUtil;
import com.lianzhihui.romeex.utils.NoDoubleClickUtils;
import com.lianzhihui.romeex.utils.NumberUtils;
import com.lianzhihui.romeex.utils.StatusBarUtil;

import java.text.MessageFormat;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * @ProjectName: romeex
 * @Package: com.lianzhihui.romeex.ui.wallet
 * @ClassName: ReceiveRecordDetails
 * @Description: 积分转账详情
 * @Author: zhanghong
 * @CreateDate: 2020/11/11 17:41
 * @UpdateUser: 更新者：
 * @UpdateDate: 2020/11/11 17:41
 * @UpdateRemark: 更新说明：
 * @Version: 1.0
 */
public class IntegralTransferDetailsActivity extends BaseActivity {

    @BindView(R.id.include_top_lin_background)
    LinearLayout includeTopLinBackground;
    @BindView(R.id.iv_icon)
    ImageView iv_icon;
    @BindView(R.id.tv_sum)
    TextView tv_sum;
    @BindView(R.id.tv_time)
    TextView tv_time;
    @BindView(R.id.tv_fee)
    TextView tv_fee;
    @BindView(R.id.tv_address_from)
    TextView tv_address_from;
    @BindView(R.id.tv_address_to)
    TextView tv_address_to;
    @BindView(R.id.tv_state)
    TextView tv_state;
    TradeRecordBean.DetailBean details;

    String hash;

    @Override
    protected int getLayoutId() {
        return R.layout.activity_integral_transfer_details;
    }

    @Override
    protected void initView() {
        StatusBarUtil.setTransparent(this);
        StatusBarUtil.setStatusBarTextColor(this, false);
        includeTopLinBackground.setBackgroundColor(getResources().getColor(R.color.transparent));


    }


    @Override
    protected void initData() {
        Bundle extras = getIntent().getExtras();
        if (extras != null) {
            MnnerTransferListBean.ContentBean item = (MnnerTransferListBean.ContentBean) extras.get(AppConstants.RECORD_DETAILS_KEY);
            if (item == null) {
                return;
            }
            iv_icon.setImageResource(R.drawable.icon_integral);
            String temp = "";
            if (Double.parseDouble(item.getBalance()) > 0) {
                temp = "+" + NumberUtils.big8(Double.parseDouble(item.getBalance()));
                tv_address_from.setText(item.getTargetAddress());
                tv_address_to.setText(item.getWalletAddress());
                setTitle(getResources().getString(R.string.text_node_payment_details));
                tv_state.setText(getResources().getString(R.string.text_get_money_success));
            } else {

                temp = NumberUtils.big8(Double.parseDouble(item.getBalance()));
                tv_address_from.setText(item.getWalletAddress());
                tv_address_to.setText(item.getTargetAddress());
                setTitle(getResources().getString(R.string.text_trans_recode_detail));
                tv_state.setText(getResources().getString(R.string.text_trans_success));
            }
            tv_sum.setText(MessageFormat.format("{0}" + getString(R.string.text_xusd), temp));
            tv_time.setText(DateUtil.sec2Date(item.getTimeStamp()));
            tv_fee.setText(item.getFee());


        }
    }

    @OnClick({R.id.tv_address_from, R.id.tv_address_to})
    public void OnClick(View v) {
        if (NoDoubleClickUtils.isDoubleClick()) {
            switch (v.getId()) {
                case R.id.tv_address_from:
                    copyString(tv_address_from.getText().toString());
                    break;
                case R.id.tv_address_to:
                    copyString(tv_address_to.getText().toString());
                    break;

                default:
                    break;
            }
        }
    }


}
